#include <stdio.h>


int maximumProduct(int* nums, int numsSize)
{
    int max = 1;
    for(int i = 1;i < numsSize;i++)
    {
        int j = i;
        int temp = nums[j];
        for(;j > 0;j--)
        {
            if(nums[j - 1] < temp)
                nums[j] = nums[j - 1];
            else
                break;

        }
        nums[j] = temp;
    }
    if(nums[2] >= 0)
        return max = nums[0] * nums[1] * nums [2]; 
    if(nums[0] > 0 && nums[1] < 0)
        return max = nums[0] * nums[numsSize - 1] * nums [numsSize - 2]; 
}

int main()
{
    int nums[] = {-1,-2,-3,6};
    int numsSize = sizeof(nums)/sizeof(nums[0]);
    int n = maximumProduct(nums, numsSize);
    for(int i = 0;i < numsSize;i++)
        printf("%d ",nums[i]);
    printf("\n%d\n",n);
    return 0;
}